<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/resources/layout/templateInterno.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:rich="http://richfaces.org/rich">
    
	<ui:define name="body">
		<div class="grid-11-12">
			<h:panelGroup id="exibirTitulo">
				<h:panelGroup rendered="#{igrejaCadastroBean.acaoTela != ''}">
					
						<h1>#{igrejaCadastroBean.acaoTela} IGREJA</h1>
					
				</h:panelGroup>
				<h:panelGroup rendered="#{igrejaCadastroBean.acaoTela == ''}">
					<div class="grid-11-12">
						<h1>PESQUISAR IGREJA</h1>
					</div>
				</h:panelGroup>
			</h:panelGroup>
		</div>
		<div class="form">
		<div  class="field-clear"></div>
		<h:form id="formCadastroIgreja">
		<h:panelGroup id="pgMensagens">
						<h:messages layout="table" errorClass="errorMessage" infoClass="infoMessage" />
		</h:panelGroup>
		<div  class="field-clear"></div>
		<h:panelGroup rendered="#{igrejaCadastroBean.exibirCadastro}" id="pgDadosPessoais">
			  <t:fieldset id="idfsDadosPessoais"  legend="Dados">
			  
					<div class="grid-5-12">
						<em class="form-req">*</em>
						<h:outputLabel  id="lbNome" class="form-lbl"  value="Nome:"/>
						<h:inputText maxlength="100"  id="inptNome" styleClass="form-txt" required="true" label="Nome" value="#{igrejaCadastroBean.igreja.nome}" />
					</div>
					<div class="grid-3-12">
						<h:outputLabel  id="lbCnpj" class="form-lbl"  value="CNPJ:"/>
						<h:inputText  id="inptCnpj" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cnpj}" >
							 <rich:jQuery selector="#inptCnpj" query="mask('99.999.999/9999-99')" timing="onload"/>
						</h:inputText>					
					</div>
					 <div class="field-clear"></div>
					 <div class="grid-2-12">
						<h:outputLabel  id="lbCep" class="form-lbl"  value="CEP:"/>
						<h:inputText  id="inptCep" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cep}" >
							 <rich:jQuery selector="#inptCep" query="mask('99999-999')" timing="onload"/> 
						</h:inputText>					
					</div>
					 <div class="grid-4-12">
						<h:outputLabel  id="lbLogradouro" class="form-lbl"  value="Logradouro:"/>
						<h:inputText id="inptLogradouro" maxlength="100"  styleClass="form-txt" value="#{igrejaCadastroBean.igreja.logradouro}" />
					</div>
					<div class="grid-2-12">
						<h:outputLabel  id="lbNumero" class="form-lbl"  value="Número:"/>
						<h:inputText style="width: 50px" id="inptNumero" maxlength="6"  styleClass="form-txt" value="#{igrejaCadastroBean.igreja.numero}" >
							 <rich:jQuery selector="#inptNumero" query="numeric()" timing="onload"/>
						</h:inputText>
					</div>
					 <div class="field-clear"></div>	
					<div class="grid-4-12">
						<h:outputLabel  id="lbBairro" class="form-lbl"  value="Bairro:"/>
						<h:inputText  id="inptBairro" maxlength="100" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.bairro}" />
					</div>
					<div class="grid-4-12">
						<h:outputLabel  id="lbCidade"  class="form-lbl"  value="Cidade:"/>
						<h:inputText  id="inptCidade" maxlength="60"  styleClass="form-txt" value="#{igrejaCadastroBean.igreja.cidade}" />
					</div>	
						
					<div class="grid-2-12" style="width: 60px">
						<h:outputLabel  id="lbUf" class="form-lbl"  value="UF:"/>
						<h:selectOneMenu  style="width: 100px"  id="cbUf" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.uf}">
					 		<f:selectItem itemLabel="Selecione ..." itemValue=""/>
					 		<f:selectItems value="#{igrejaCadastroBean.listaUfs}" />
				 		</h:selectOneMenu>
					</div>
					<div class="field-clear"></div>
					<div class="grid-3-12">
						<em class="form-req">*</em>
						<h:outputLabel  id="lbDataInauguracao" class="form-lbl"  value="Data Inauguração:"/>
						<rich:calendar  required="true" label="Data Inauguração"  id="clDtInicial" firstWeekDay="0" minDaysInFirstWeek="2"
								value="#{igrejaCadastroBean.igreja.dtInauguracao}" 
								datePattern="dd/MM/yyyy" 
								inputSize="10" 
								showWeeksBar="false"
								inputClass="maskDate"
								enableManualInput="true" 
								disabled="false">
						</rich:calendar>
						<rich:jQuery id="mskDateCasamento" selector=".maskDate" timing="onload" query="mask('99/99/9999',{placeholder:' '})" />									
					</div>
					<div class="grid-3-12">
						<em class="form-req">*</em>
						<h:outputLabel  id="lbSituacao" class="form-lbl"  value="Situação:"/>
						<h:selectOneMenu  required="true" label="Situação" id="cbSituacao" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.situacao}">
					 		<f:selectItem itemLabel="Selecione ..." itemValue=""/>
					 		<f:selectItem itemLabel="IGREJA" itemValue="I"/>
					 		<f:selectItem itemLabel="CONGREGAÇÃO" itemValue="C"/>
				 		</h:selectOneMenu>
					</div>
					 <div class="field-clear"></div>
					<div class="grid-2-12">
						<h:outputLabel  id="lbTelefone" class="form-lbl"  value="Telefone:"/>
						<h:inputText  id="inptTelefone" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.telefone}" >
							 <rich:jQuery selector="#inptTelefone" query="mask('(99) 9999-9999')" timing="onload"/> 
						</h:inputText>					
					</div>
					<div class="grid-2-12">
						<h:outputLabel  id="lbTelefone2" class="form-lbl"  value="Telefone 2:"/>
						<h:inputText  id="inptTelefone2" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.segundoTelefone}" >
							<rich:jQuery selector="#inptTelefone2" query="mask('(99) 9999-9999')" timing="onload"/>
						 </h:inputText>
										
					</div>
					<div class="grid-2-12">
						<h:outputLabel  id="lbCelular" class="form-lbl"  value="Celular:"/>
						<h:inputText  id="inptCelular" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.celular}" >
							<rich:jQuery selector="#inptCelular" query="mask('(99) 9999-9999')" timing="onload"/>
						</h:inputText>					
					</div>
					<div class="grid-5-12">
						<em class="form-req">*</em>
						<h:outputLabel  id="lbEmail" class="form-lbl"  value="E-mail:"/>
						<h:inputText  id="inptEmail" style="text-transform: lowercase;" maxlength="200" required="true" label="E-mail" styleClass="form-txt" value="#{igrejaCadastroBean.igreja.email}" />					
					</div>
			 </t:fieldset>
		 
		 </h:panelGroup>
		 
			
		
		<div  class="field-clear"> </div>
		<h:panelGroup id="pgSalvarPorPerfil" rendered="#{usuarioLogado.exibirSalvar}">
		 	<h:panelGroup id="pgBotaoSalvar" rendered="#{igrejaCadastroBean.exibirBotaoSalvar}">
				 <div  class="grid-2-12">
						<a4j:commandButton styleClass="form-button" id="cbSalvar" value="Salvar" reRender="formCadastroIgreja,exibirTitulo" action="#{igrejaCadastroBean.salvar}" >	</a4j:commandButton>
				</div >
			</h:panelGroup>
		</h:panelGroup>
		<h:panelGroup id="pgEditarPorPerfil" rendered="#{usuarioLogado.exibirSalvar}">
			<h:panelGroup id="pgBotaoAtualizar" rendered="#{igrejaCadastroBean.exibirBotaoAtualizar}">
				 <div  class="grid-2-12">
						<a4j:commandButton  styleClass="form-button" id="cbAtualizar" value="Atualizar" reRender="formCadastroIgreja,exibirTitulo" action="#{igrejaCadastroBean.salvar}" >	</a4j:commandButton>
				</div >
			</h:panelGroup>
		</h:panelGroup>
			<h:panelGroup id="pgBotaoBotaoVoltar" rendered="#{igrejaCadastroBean.exibirBotaoVoltar}">
				 <div  class="grid-2-12">
						<a4j:commandButton  styleClass="form-button" immediate="true" id="cbVoltar" value="Voltar" reRender="formCadastroIgreja,exibirTitulo" action="#{igrejaCadastroBean.voltar}" >	</a4j:commandButton>
				</div >
			</h:panelGroup>
			
			<h:panelGroup id="pgExcluirPorPerfil" rendered="#{usuarioLogado.exibirExcluir}">
				<h:panelGroup id="pgBotaoBotaoExcluir" rendered="#{igrejaCadastroBean.exibirBotaoExcluir}">
					 <div class="grid-2-12">
							<a4j:commandButton onclick="Richfaces.showModalPanel('modalPanelConfirmaExcluir');" styleClass="form-button" id="cbExcluir" value="Excluir" reRender="formCadastroIgreja" >	</a4j:commandButton>
					</div >
				</h:panelGroup>	
			</h:panelGroup>
		<div class="field-clear"></div>
		
		<h:panelGroup   rendered="#{igrejaCadastroBean.exibirPesquisa}" >
			 <t:fieldset id="idfsDadosIgreaj" style="width: 600px; float: left" legend="Filtros">
			 	
			 		 <div class="grid-7-12">
						<h:outputLabel class="form-lbl"  value="Nome:"/>				
						<h:inputText styleClass="form-txt" maxlength="100" value="#{igrejaCadastroBean.igrejaPesquisa.nome}" id="nomePesquisa" />
					 </div>
					  
				</t:fieldset>
					<div class="field-clear"></div>
			 		<div class="grid-2-12">
						<a4j:commandButton id="cbPesquisar" process="idfsDadosIgreaj" ajaxSingle="true"  styleClass="form-button" action="#{igrejaCadastroBean.pesquisarIgreja}" reRender="pgTabelaIgrejas,pgResultadoas,pgMensagens" value="Pesquisar" >
						</a4j:commandButton>
					</div>
					<h:panelGroup id="pgNovoPorPerfil" rendered="#{usuarioLogado.exibirNovo}">
						<div class="grid-2-12">
							<a4j:commandButton  styleClass="form-button" id="cbNovo" value="Novo" reRender="formCadastroIgreja,exibirTitulo" action="#{igrejaCadastroBean.novo}" >	</a4j:commandButton>
						</div>
					</h:panelGroup>
			 <div class="field-clear"></div>
			 <div class="grid-12-12" style="padding-left: 40px" >
				 <h:panelGroup id="pgTabelaIgrejas">
					 	<rich:dataTable   rendered="#{not empty igrejaCadastroBean.listaIgrejas}"
		                    			 styleClass="dataTable rich-table rich-table-cell ui-widget-content ui-grid-content" rows="10" 
		                    			width="750" border="0" align="center" id="igrejaTable"  var="igreja" value="#{igrejaCadastroBean.listaIgrejas}" >
						  <f:facet  name="header">
		                    <rich:columnGroup >
		                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Nome" /></strong>
		                            </rich:column>
		                            <rich:column style="text-align: center;"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="CNPJ" /></strong>
		                            </rich:column>
		                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Telefone" /></strong>
		                            </rich:column>
		                             <rich:column style="text-align: center;"  styleClass="ui-state-default" >
		                                <strong><h:outputText value="Ação" /></strong>
		                            </rich:column>
		                    	</rich:columnGroup>
		                  </f:facet>
		 				<rich:columnGroup >	
							 <rich:column style="text-align: center;" >
								<h:outputText value="#{igreja.nome}" />
							</rich:column>
							<rich:column  style="text-align: center;">
								<h:outputText value="#{igreja.cnpj}" />
							</rich:column>
							<rich:column style="text-align: center;" >
								<h:outputText value="#{igreja.telefone}" />
							</rich:column>
							<rich:column style="text-align: center;" >
								<a4j:commandLink id="editarIgreja" action="#{igrejaCadastroBean.editar}" ajaxSingle="true" reRender="formCadastroIgreja"  >
									<h:graphicImage value="/resources/imagens/ico_editar.gif" id="gIEdidarIgreja" styleClass="hidelink"/>
									 <f:setPropertyActionListener target="#{igrejaCadastroBean.igreja}" value="#{igreja}"/>  
								</a4j:commandLink>
								<h:panelGroup rendered="#{usuarioLogado.exibirExcluir}">
										<a4j:commandLink id="remover" ajaxSingle="true" 
												onclick="Richfaces.showModalPanel('modalPanelConfirmaExcluir');"
												 reRender="membroPesquisaTable"  >
											 <h:graphicImage value="/resources/imagens/ico_excluir.gif" id="gIExcluirUsers" styleClass="hidelink"/>
										   <f:setPropertyActionListener target="#{igrejaCadastroBean.igreja}" value="#{igreja}"/>
										</a4j:commandLink>
							</h:panelGroup>
							</rich:column>
						</rich:columnGroup>
					</rich:dataTable>
					 <div class="field-clear"></div>
					<div class="grid-12-12">
						<rich:datascroller align="center" status="" renderIfSinglePage="false" for="igrejaTable" />
					</div>
				</h:panelGroup>
			</div>
			
			<h:panelGroup id="pgResultadoas">
			<div class="grid-12-12">
					<h:outputText styleClass="infoRegistroNaoEnc" value="#{msg['info.MGS_01']}" rendered="#{igrejaCadastroBean.registroNaoEncontrado}" />
			</div>
			</h:panelGroup>
		
		</h:panelGroup>
		</h:form>
		</div>
		
		<rich:modalPanel id="modalPanelConfirmaExcluir" width="280"
					autosized="false" resizeable="false" height="110">
			<div class="form">
			<h:form id="fomModal" >
					<center>
						<div style="margin-left: 40px; margin-bottom: 30px" class="grid-9-12" >
							<h:outputText styleClass="infoRegistroNaoEnc" value="#{msg['info.MSG_02']}"  />
						</div>	
						 <div class="field-clear"></div>
						<div style="margin-left: 60px" class="grid-3-12" >
							<a4j:commandButton ajaxSingle="true" value="Confirmar" action="#{igrejaCadastroBean.excluir}" 
								id="btnConfirmar" styleClass="form-button"
								reRender="formCadastroIgreja,exibirTitulo" oncomplete="Richfaces.hideModalPanel('modalPanelConfirmaExcluir');"  style="width=50px">
							</a4j:commandButton>
						</div>	
						<div style="margin-left: 10px" class="grid-3-12" >
							<a4j:commandButton ajaxSingle="true" value="Cancelar" 				id="btnCancelar" styleClass="form-button"
								onclick="Richfaces.hideModalPanel('modalPanelConfirmaExcluir');"  style="width=50px">
							</a4j:commandButton>
						</div>	
					</center>
			</h:form>
		</div>
		</rich:modalPanel>
		
		<t:saveState  value="#{igrejaCadastroBean.registroNaoEncontrado}"/>
		<t:saveState  value="#{igrejaCadastroBean.exibirCadastro}"/>
	   	<t:saveState  value="#{igrejaCadastroBean.exibirBotaoNovo}"/>	      
	    <t:saveState  value="#{igrejaCadastroBean.exibirBotaoAtualizar}"/>
	    <t:saveState  value="#{igrejaCadastroBean.exibirBotaoExcluir}"/>
	    <t:saveState  value="#{igrejaCadastroBean.exibirBotaoVoltar}"/>
		<t:saveState  value="#{igrejaCadastroBean.exibirBotaoSalvar}"/>
		<t:saveState  value="#{igrejaCadastroBean.exibirPesquisa}"/> 	
		<t:saveState value="#{igrejaCadastroBean.igrejaPesquisa}"/>
		<t:saveState value="#{igrejaCadastroBean.igreja}"/>
		<t:saveState value="#{igrejaCadastroBean.listaIgrejas}"/>  
	</ui:define>
</ui:composition>

